$(function() {
	function appendFall(sj,box) {
		//热门推荐内容填充
		var c=sj;
		for (var i = 0; i < c.length; i++) {
			var b_img = c[i].brandimg;
			var b_logo = c[i].logo;
			var b_ms = c[i].describe;
			var b_pp = c[i].brand;
			var brand2 = '';
			brand2 = `
				<li class="main-three-li">
						<a href="" class="main-three-li-a">
							<img src="${b_img}" alt="">
							<div class="main-three-li-div">
								<p class="main-three-p">品牌描述</p>
								<p class="main-three-p1"><span>${b_ms}</span></p>
							</div>
							<div class="main-three-li-div3">
							</div>
						</a>
						<div class="main-three-li-div2">
							<a href="javascript:void(0)" class="main-three-li-a2">
								<div class="main-three-li-a2-div">
									<i class="bi bi-heart"></i><span>关注</span>
								</div>
							</a>
							<img src="${b_logo}" alt="">
						</div>
						<p class="main-three-p2">${b_pp}</p>
					</li>
				`;
			$(box).append(brand2);
	
		}
	}
	appendFall(brandJSON,'.one');
	appendFall(brandJSON2,'.two');
	appendFall(brandJSON3,'.three');
	appendFall(brandJSON4,'.four');
	appendFall(brandJSON5,'.five');
	appendFall(brandJSON6,'.six');
	appendFall(brandJSON7,'.seven');
	appendFall(brandJSON8,'.eight');
	appendFall(brandJSON9,'.nine');
	// appendFall()
	// 点击回顶部
	$(window).scroll(function(event) {
		/* Act on the event */
		if ($(this).scrollTop() == 0) {
			$(".hdb").hide();
		}
		if ($(this).scrollTop() != 0) {
			$(".hdb").show();
		}
	});
	$(".hdb").click(function(event) {
		/* Act on the event */
		$("html,body").animate({
				scrollTop: "0px"
			},
			666
		)
	});




	//到页面底部追加一个li
	$(window).scroll(function() {
		var scrollTop = $(this).scrollTop();
		var scrollHeight = $(document).height();
		var windowHeight = $(this).height();
		if (scrollTop <= 4000) {
			if (scrollTop + windowHeight == scrollHeight) {
				var jia = appendFall(brandJSON,'.one');
				// console.log(scrollTop);
				$('.main-three-one').insertAfter(jia);
				// console.log("到底了,发起请求")
			}
		}

	});
	













	

	$('.brand').click(function() {
		$(this).addClass('main-two-a').siblings().removeClass('main-two-a')
		var index = $('.brand').index($(this));
		// console.log(index);
		$('.main-three-one').eq(index).show().siblings('.main-three-one').hide();

	})



	// 登录和蒙版
	$('.main-three-li-a2-div').click(function() {
		$('.login-btn').show();
		$(' #close').show();
	})
	$('.derror').click(function() {
		$(this).parents('.login-btn').hide();
		$(' #close').hide();
	})



})
